/*
 * <p>ClassName: Files </p>
 * <p>Description: Files类文件 </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: sinosoft </p>
 * @Database: 江泰
 * @CreateDate：2003-06-17
 */
package com.yehongyu.mytools.basic.util.collection;

import java.util.Enumeration;
import java.util.Hashtable;

public class Request {

	Request() {
		m_parameters = new Hashtable<String,Hashtable<Integer,String>>();
		m_counter = 0;
	}

	protected void putParameter(String name, String value) {
		if (name == null)
			throw new IllegalArgumentException(
					"The name of an element cannot be null.");
		if (m_parameters.containsKey(name)) {
			Hashtable<Integer,String> values = m_parameters.get(name);
			values.put(new Integer(values.size()), value);
		} else {
			Hashtable<Integer,String> values = new Hashtable<Integer,String>();
			values.put(new Integer(0), value);
			m_parameters.put(name, values);
			m_counter++;
		}
	}

	public String getParameter(String name) {
		if (name == null)
			throw new IllegalArgumentException(
					"Form's name is invalid or does not exist (1305).");
		Hashtable<Integer,String> values = m_parameters.get(name);
		if (values == null)
			return null;
		else
			return (String) values.get(new Integer(0));
	}

	public Enumeration<String> getParameterNames() {
		return m_parameters.keys();
	}

	public String[] getParameterValues(String name) {
		if (name == null)
			throw new IllegalArgumentException(
					"Form's name is invalid or does not exist (1305).");
		Hashtable<Integer,String> values = m_parameters.get(name);
		if (values == null)
			return null;
		String strValues[] = new String[values.size()];
		for (int i = 0; i < values.size(); i++)
			strValues[i] = (String) values.get(new Integer(i));

		return strValues;
	}

	private Hashtable<String,Hashtable<Integer,String>> m_parameters;
	private int m_counter;
}
